package com.ys.controller.api.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.sys.YsModalSelector;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.YsModalSelectorService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/inter/ysModalSelector")
public class ApiInterYsModalSelectorController {
	
	public static Long MENU_ID = 49L;
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<YsModalSelector> commonApiService;
	@Autowired
	private YsModalSelectorService ysModalSelectorService;

	@RequiresPermissions("ysModalSelector:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute YsModalSelector cond
			){
		
		cond.setOrderby("A.Id asc");
		
		return commonApiService.searchLay(cond);
	}
	
	/**
	 * 新增
	 */
	@PostMapping("/add")
    @ResponseBody
	public R add(Model model, HttpServletRequest request, HttpServletResponse response,
			String name, String nameTable, String pathGridRequest){
		
		return ysModalSelectorService.add(name, nameTable, pathGridRequest);
	}
	
	/**
	 * 编辑
	 */
	@PostMapping("/edit")
    @ResponseBody
	public R edit(Model model, HttpServletRequest request, HttpServletResponse response,
			Long id, String name, String nameTable, String pathGridRequest){
		
		return ysModalSelectorService.edit(id, name, nameTable, pathGridRequest);
	}
	
	/*
	 * 彻底删除
	 */
	@PostMapping("/deleteTrue")
	@ResponseBody
	public R deleteTrue(HttpServletRequest request, HttpServletResponse response,
			Long id) {
		return ysModalSelectorService.deleteTrue(id);
	}
	
	/*
	 * 弹出框配置信息
	 */
	@PostMapping("/modalConfig")
	@ResponseBody
	public R modalConfig(
			String modalKey,
			Integer multySelected) {
		return ysModalSelectorService.modalConfig(
				modalKey,
				multySelected);
	}
	
}
